<template>
  <div class="login">
    <div class="l-con">
      <van-icon name="wap-home-o" color="#fff" size="40" @click="$router.push('/home')"/>
      <van-notice-bar scrollable text="苏宁魂，苏宁人，苏宁会员都是人上人！！！🐕💪🙈🎉🎉🎉🎊🎇✨" />
      <!-- 输入任意文本 -->
      <van-field v-model="username" label="用户名" />
      <!-- 输入密码 -->
      <van-field v-model="password" type="password" label="输入密码" />
      <van-button color="linear-gradient(to right, #ff6034, #ee0a24)" size="large" @click="login">登录</van-button>
      <div class="l-c-bottom">
      </div>
    </div>
  </div>
</template>

<script>
import { getRecommends } from '@api'
export default {
  data () {
    return {
      username: '',
      password: '',
      lives: []
    };
  },
  created () {
    this.setRecommends()
  },
  methods: {
    login () {
      setTimeout(() => {
        // 点击登录后，存储 token
        const token = 'jshfsajfgqhfsgvhsbjkag'
        localStorage.setItem('access_token', token)
        // 回到 重定向之前的 路由
        if (this.$route.params.from) {
          this.$router.push(this.$route.params.from)
        } else {
          this.$router.push('/home')
        }
      }, 1000)
    },
     // 猜你喜欢
    setRecommends () {
      getRecommends().then(res => {
        this.isLoading = false
        // console.log(res);
        if (res.data.code === 0) {
          if (this.isFirst) {
            Toast('刷新完成了')
          }
          this.lives = res.data.data
        }
      })
    },
  },
}
</script>

<style lang="scss" scoped>
.login {
  height: 666px;
  background: url("../../assets/image/bg.gif") 100% 100%;
  display: flex;
  .l-con {
    margin: auto;
    width: 80%;
    height: 100%;
    border-radius: 47px;
    box-shadow: 21px 21px 42px #d6d6d6, -21px -21px 42px #ffffff;
    padding: 20px;
    /deep/.van-notice-bar {
      border-radius: 12px;
    }
    .van-cell {
      margin: 20px 0;
      border-radius: 12px;
    }
    .l-c-bottom {
      width: 150px;
      height: 150px;
      margin: 0 auto;
      margin-top: 12px;
      border-radius: 10px;
      background: url("../../assets/image/666plus.gif") 100% 100% no-repeat;
      background-size: contain;
    }
  }
}

.van-icon {
  margin-bottom: 20px;
}
</style>